//
//  CopyAndPasteView.m
//  分享demo
//
//  Created by pc-chtypd056 on 2018/8/28.
//  Copyright © 2018年 CTL. All rights reserved.
//

#import "CopyAndPasteView.h"
#import <WebKit/WebKit.h>

@interface CopyAndPasteView()

@property (nonatomic, strong) WKWebView *webView;

@end

@implementation CopyAndPasteView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpSubView];
    }
    return self;
}

- (void)setUpSubView{
    
    [self addSubview:self.webView];
    
    NSString *stirng = [[[NSBundle mainBundle]infoDictionary]objectForKey:@"CFBundleIdentifier"];
    UIPasteboard *board = [UIPasteboard pasteboardWithName:stirng create:NO];
    UITextField *label = [[UITextField alloc]initWithFrame:CGRectMake(0, self.webView.height, self.width, self.height/2)];
    label.text = board.string;
    label.backgroundColor = [UIColor blueColor];
    [self addSubview:label];
}

- (WKWebView *)webView{
    if (!_webView) {
        _webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, self.width, self.height/2)];
        [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.baidu.com"]]];
        _webView.allowsBackForwardNavigationGestures = YES;
    }
    return _webView;
}

@end
